package ZY11_05.ArrayLink;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ArrayLink {
    public static void main(String[] args) {
        List list = new ArrayList();
        List link=new LinkedList();
        long start=System.nanoTime();
        for (int i=0;i<100000;i++){
            list.add(i);
        }
        long start1=System.nanoTime();
        for (int i=0;i<100000;i++){
            link.add(i);
        }
        long start2=System.nanoTime();
        System.out.println("ArrayList:"+(start1-start));
        System.out.println("LinkedList:"+(start2-start1));
        long start3=System.nanoTime();
        for (int i=0;i<100;i++){
            list.remove(i);
        }
        long start4=System.nanoTime();
        long start5=System.nanoTime();
        for (int i=0;i<100;i++){
            link.remove(i);
        }
        long start6=System.nanoTime();
        System.out.println("ArrayList:"+(start4-start3));
        System.out.println("LinkedList:"+(start6-start5));
//        System.out.println("耗时："+(System.currentTimeMillis()-start));
//        System.out.println("**********************************");
//        List<Integer> list1=new LinkedList<>();
//        for (int i=0;i<100000;i++){
//            list1.add(i);
//        }
//        long start1=System.currentTimeMillis();
//        for (int j=0;j<list1.size();j++){
//            System.out.println(list1.get(j));
//        }
//        System.out.println("耗时："+(System.currentTimeMillis()-start1));
    }
}
